package GameLogic

import (
	. "Servers/BaseServer"

	. "git.oschina.net/yangdao/extlib/data_type"
)

type GameScene struct {
	SceneUnits *TypVector
}

func NewGameScene() *GameScene {
	newGameScene := &GameScene{
		SceneUnits: Vector(),
	}
	return newGameScene
}

func (this *GameScene) OnLoad(mapId int, players []IPlayer, sceneServerID int) {
	for i := 0; i < len(players); i++ {
		unitName := players[i].GetReadyPlayerInfo().GetSelectSpriteID()
		this.AddUnit(UnitManager.Create(unitName, players[i]))
	}
}

func (this *GameScene) AddUnit(unit IUnit) {
	this.SceneUnits.Conj(unit)
}

func (this *GameScene) RemoveUnit(id int64) {
	for i := 0; i < this.SceneUnits.Count(); i++ {
		if this.SceneUnits.Nth(i).(IUnit).Base().UUID == id {
			this.SceneUnits.RemoveAt(i)
			break
		}
	}
}

func (this *GameScene) Update(dt float64) {

}
